package cn.frank.config;

//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.scheduling.annotation.EnableAsync;
//import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
//
//import java.util.concurrent.Executor;
//
///**
// * @author Frank 启用
// * @date 05-29
// */
//@Configuration
//@EnableAsync
//public class AsyncConfig {
//    @Bean(name = "taskExecutor")
//    public Executor taskExecutor() {
//        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
//        executor.setCorePoolSize(5); // 核心线程数
//        executor.setMaxPoolSize(10); // 最大线程数
//        executor.setQueueCapacity(25); // 队列容量
//        executor.setKeepAliveSeconds(60); // 线程存活时间
//        executor.setAllowCoreThreadTimeOut(true); // 允许核心线程超时
//        //executor.setThreadNamePrefix("MyAsyncThread-"); // 线程名前缀
//        // 可以设置拒绝策略，如下面的代码表示拒绝直接在调用者线程中运行任务
//        // executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
//        executor.initialize();
//        return executor;
//    }
//}
